package com.ecommerce.dal.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecommerce.dal.dao.impl.ItemDAO;
import com.ecommerce.dal.dao.impl.ItemDetailDAO;
import com.ecommerce.dal.entity.Item;
import com.ecommerce.dal.entity.ItemDetail;
import com.ecommerce.dal.service.IItemManagerService;

@Service("itemManagerService")
public class ItemManagerService implements IItemManagerService {

	@Autowired
	ItemDAO itemDAO;
	@Autowired
	ItemDetailDAO itemDetailDAO;

	@Override
	public Item retrieveItem(long itemId) {
		return itemDAO.findByItemId(itemId);
	}

	@Override
	public void saveItem(Item item) {
		itemDAO.save(item);

	}

	@Override
	public void saveItemDetails(ItemDetail itemDetails) {
		itemDetailDAO.save(itemDetails);

	}

	@Override
	public List<ItemDetail> retrieveItemDetails(long itemId) {
		return itemDetailDAO.findByItemId(itemId);
	}

	@Override
	public List<Item> retrieveItemByCategory(long categoryId) {
		return itemDAO.findItemByCategory(categoryId);
	}

	@Override
	public List<Item> retrieveItemByClient(long clientId) {
		return itemDAO.findItemByClientId(clientId);
	}

	@Override
	public List<Item> retrieveItemByClient(String clientUsername) {
		return itemDAO.findItemByClientUserName(clientUsername);

	}

	@Override
	public List<Item> retrieveItemByCompany(long companyId) {
		return itemDAO.findItemByCompany(companyId);
	}

	@Override
	public List<Item> retrieveItemByPrice(Double minPrice, Double maxPrice) {
		return itemDAO.findItemByPrice(minPrice, maxPrice);
	}

	@Override
	public List<Item> retrieveItemByDiscount(Double minDiscount,
			Double maxDiscount) {
		return itemDAO.findItemByDiscount(minDiscount, maxDiscount);
	}

	@Override
	public List<Item> retrieveDiscountedItems() {
		return itemDAO.findDiscountedItems();
	}

	@Override
	public void deleteItem(Item item) {
		itemDAO.delete(item);
	}

	@Override
	public void updateItem(Item item) {
		itemDAO.update(item);
		
	}
	

	// @Override
	// public Double retrieveItemPrice(Long itemID) {
	// // TODO Auto-generated method stub
	// return null;
	// }

	// @Override
	// public Double retrieveItemDiscount(Long itemID) {
	// // TODO Auto-generated method stub
	// return null;
	// }
	//

}
